import initial.Init;
import loginTest.Login;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import java.util.List;
import java.util.concurrent.TimeUnit;

import static java.lang.Thread.sleep;

public class Test extends Login {
    @Override
    @ParameterizedTest
    @CsvSource("https://ceshi.cadexam.com:5555/resource-platform/#/login?redirect=/resource/title/titlemanage,zhangye1,zhangye1,https://ceshi.cadexam.com:5555/resource-platform/#/resource/title/titlemanage")
    @Order(1)
    public void login(String url, String username, String password, String newUrl) throws InterruptedException {
        super.login(url, username, password, newUrl);
    }
    @org.junit.jupiter.api.Test
    void test01() throws InterruptedException {
        //打开左侧栏
//        webDriver.findElement(By.cssSelector("#hamburger-container")).click();
        //选择图纸管理
        webDriver.findElement(By.cssSelector("#app > div > div.has-logo.sidebar-container > div.el-scrollbar.theme-dark > div.scrollbar-wrapper.el-scrollbar__wrap.el-scrollbar__wrap--hidden-default > div > ul > div:nth-child(2) > li > div")).click();
        sleep(1000);
        webDriver.findElement(By.cssSelector("#app > div > div.has-logo.sidebar-container > div.el-scrollbar.theme-dark > div.scrollbar-wrapper.el-scrollbar__wrap.el-scrollbar__wrap--hidden-default > div > ul > div:nth-child(2) > li > ul > div:nth-child(1)"))
                .click();
        webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
        sleep(3000);
        //点击 新建
        webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/section/div/div/div[1]/div[1]/button[1]")).click();
        sleep(3000);
        //输入图纸名
        sleep(3000);
        webDriver.findElement(By.cssSelector(".el-dialog__body .el-form-item__content .el-input__wrapper .el-input__inner")).sendKeys("测试");
        //定位专业下拉框
        List<WebElement> elements =  webDriver.findElements(By.cssSelector(".el-overlay-dialog .el-form-item__content .el-input__wrapper .el-input__inner"));
        elements.get(1).click();
        //选择机械专业
        webDriver.findElement(By.xpath("/html/body/div[2]/div[37]/div/div/div[1]/ul/li[1]")).click();
        //上传dwg图纸
        webDriver.findElement(By.cssSelector(" .el-upload  .el-upload__input[accept=\".dwg\"]")).sendKeys("C:\\Users\\admin\\Desktop\\资源平台测试数据\\dwg图纸\\B1.dwg");
        sleep(3000);
        //点击保存
        webDriver.findElement(By.xpath("/html/body/div[43]/div/div/footer/span/button[1]")).click();
        sleep(3000);
    }
}
